<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>我的工资</title>
		<link rel="stylesheet" href="../static/css/xadmin.css">
		<link rel="stylesheet" href="../static/css/xadmin.css">
		<script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
		<script src="../static/lib/layui/layui.js" charset="utf-8"></script>
		<script type="text/javascript" src="../static/js/xadmin.js"></script>
		<script src="../static/js/my.js"></script>
	</head>
	<body>
		
		<select id="isAdd" name="isAdd" style="width: 150px;height: 37px">
		    <option value="">请选择类型</option>
		    <option value="奖金">奖金</option>
		    <option value="罚款">罚款</option>
			 
		</select>
		<input type="button" class="layui-btn layui-btn-radius layui-btn-warm" onclick="search()" value="查询" >
			<input type="button" class="layui-btn layui-btn-radius layui-btn-warm" onclick="hui()" value="返回" >
		<table  class="layui-table" >
		    <thead>
		    <th>姓名</th>
		    <th id=is>奖金</th>
		    
		    </thead>
		    <tbody>
		   
		    </tbody>
		</table>
		
		
		
		
	</body>
</html>
<script>
	//文档加载事件
	$(function(){
			//在文档加载时查询所有记录
		
		
			selectMoney();
			
		})
	
	
	function selectMoney()
	{
		var isAdd=$("#isAdd").val();
		if(isAdd=="奖金"||isAdd=="")
		{
			isAdd="true";
		}else if(isAdd=="罚款")
		{
			isAdd="false";
		}
		
		
		
		
		if(isAdd=="true")
		{
			$("#is").text("奖金");
				$.ajax({
						url:address+"/check/countAjax",
						type:"get",
						data:{"isAdd":isAdd},
						dataType:"json",
						success:function (data) {
						   
						   //遍历分页数据,拼接字符串
						  
						 var html="";
						 
							 for(var i=0;i<data.list.length;i++)
							 {
								
								 
									 html+="<tr>"
										+"<td>"+data.list[i].userName+"</td>"
										+"<td>"+data.list[i].addMoney+"</td>"
										
									  +"</tr>"
								  
							 }
							 $("tbody").html(html);
						 }
							
							
					})
		}else
		{
			$("#is").text("罚款");
			$.ajax({
					url:address+"/check/countAjax",
					type:"get",
					data:{"isAdd":isAdd,},
					dataType:"json",
					success:function (data) {
					   
					   //遍历分页数据,拼接字符串
					  
					 var html="";
					 
						 for(var i=0;i<data.list.length;i++)
						 {
							
							 
								 html+="<tr>"
									+"<td>"+data.list[i].userName+"</td>"
									+"<td>"+data.list[i].punishMoney+"</td>"
									
								  +"</tr>"
							  
						 }
						 $("tbody").html(html);
					 }
					 
						
					
						
				})
		}
	}
	function search()
	{
		selectMoney();
	}
	function hui()
	{
		window.location.href="money.html";
	}
	
	
	
	function test()
	{
		$.ajax({
		      url:address+"/test/load",
		      type:"get",
		      
		      dataType:"json",
		      success:function(data){
		          layer.alert(data.info,function(){
										  
											    window.location.href="money.html";
										  
		             
		          })
		/*          if(data.info=="删除成功"){
		              // 第一种：刷新
		              //parent.window.location.href=parent.window.location.href;
		              //第二种：刷新
		              $(obj).parent().parent().remove();
		          }*/
		          //关闭
		          layer.close(index);
		      }
		  })
	}
</script>